import request from '@/utils/request'

// 上传图片到OSS
export function uploadImage(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/print/upload/image',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 调用阿里云分割API
export function segmentImage(imageUrl) {
  return request({
    url: '/print/upload/segment',
    method: 'post',
    data: {
      imageUrl: imageUrl
    }
  })
}

// 上传并分割图片（推荐使用）
export function uploadAndSegment(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/print/upload/upload-and-segment',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 删除OSS文件
export function deleteOssFile(url) {
  return request({
    url: '/print/upload/delete',
    method: 'delete',
    params: {
      url: url
    }
  })
} 